package com.pro.dockerdemo.controller;

import com.pro.dockerdemo.entity.Test;
import com.pro.dockerdemo.repository.TestRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/")
public class TestController {

    @Autowired
    private TestRepository testRepository;

    @GetMapping("/insert")
    public Test insertTest(Test user) {
        return testRepository.save(user);
    }

    @GetMapping(value = "/get/{id}")
    public Test getuser(@PathVariable("id") Integer id) {
        return testRepository.findById(id).get();
    }

}
